import {
	req_get,
	req_get_auth,
	req_post,
	req_post_auth
} from "./baseApi.js";
import {
	HOST
} from './hosts'

// 检查老密码是否正确
export const checkOldPasswordAPI = (params) => {
	const url = `${HOST}/users/isRight`;
	return req_get_auth("get", url, params);
}

// 修改新密码
export const changePasswordAPI = (data) => {
	const url = `${HOST}/users/changePassword`;
	return req_post_auth("put", url, data);
}
export const getAllUsers = (params) => {
	const url = `${HOST}/users/page`;
	return req_get_auth("get", url, params);
};

export const listUsers = (params) => {
	const url = `${HOST}/users`;
	return req_get_auth("get", url, params);
};
export const addUser = (data) => {
	const url = `${HOST}/users`;
	return req_post_auth("post", url, data);
};

export const deleteUser = (id) => {
	const url = `${HOST}/users/${id}`;
	return req_post_auth("delete", url);
};

export const updateUser = (data) => {
	const url = `${HOST}/users`;
	return req_post_auth("put", url, data);
};

export const login = (params) => {
	const url = `${HOST}/users/login`;
	return req_get("get", url, params);
};
export const getUserInfo = (params) => {
	const url = `${HOST}/users/userInfo`;
	return req_get_auth("get", url, params);
};
export const register = (data) => {
	const url = `${HOST}/users/register`;
	return req_post("post", url, data);
};